/*
 * @lc app=leetcode.cn id=7 lang=javascript
 *
 * [7] 整数反转
 */

// @lc code=start
/**
 * @param {number} x
 * @return {number}
 */
var reverse = function(x) {
    let type = null
    console.log(Math.pow(2,31))
    if(0-Math.pow(2,31) > x  || x > Math.pow(2,31) - 1){
        return 0
    }
    if(x < 0){
        type = true
        x = Math.abs(x)
    }
let s = x.toString();
s = s.split('');
s.reverse()
for(let i = 0 ; i < s.length; i++) {
    if(Number(s[i]) == 0){
        s.shift()
        i--
    }else{
        break
    }
}
s = s.join('')
console.log(Number(s) > Math.pow(2,31) - 1)
if(0-Math.pow(2,31) > Number(s)  || Number(s) > Math.pow(2,31) - 1){
    return 0
}
if(type){
    return -Number(s)
}
return Number(s)
};
console.log(reverse(1534236469))
// @lc code=end

